package com.wewoo.log4e.starter.mongodb.executor;

import com.wewoo.log4e.core.entity.OperationLog;
import com.wewoo.log4e.core.executor.AbstractLogExecutor;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.core.MongoTemplate;

import java.util.List;

/**
 * @ClassName DataSourceExecutor
 * @Description 操作记录 数据库执行器
 * @Author tangjin
 * @Date 16:30 2022/2/14
 **/
@RequiredArgsConstructor
public class MongodbExecutor extends AbstractLogExecutor<OperationLog> {
    private final MongoTemplate mongoTemplate;
    private Logger logger = LoggerFactory.getLogger(MongodbExecutor.class);

    @Override
    public OperationLog writeLog(OperationLog log) {
        logger.info("执行一个操作记录的入库");
        mongoTemplate.save(log);
        return log;
    }
}
